Migrate integration tests from TestServerBuilder to TestWebApplicationFactory#51
Conversation
…pdated one binding fixture usage
…6-TestWebApplicationFactoryChanges
…pdated one binding fixture usage
…RenderTypes Fixtures
This reverts commit 5f953d9.
There was a problem hiding this comment.
Pull Request Overview
This PR migrates integration tests from the legacy TestServerBuilder pattern to the standard WebApplicationFactory<TestWebApplicationProgram> pattern for ASP.NET Core integration testing. The migration preserves middleware ordering and per-test service configuration while modernizing the test infrastructure.
- Replaced
TestServerBuilder/TestServerwithWebApplicationFactory<TestWebApplicationProgram>across all integration tests and benchmarks - Preserved middleware and service ordering for each test fixture while updating configuration patterns
- Migrated benchmarks to use the new factory pattern with proper dependency injection
Reviewed Changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| TestWebApplicationProgram.cs | New test program entry point for WebApplicationFactory |
| TrackingProxyFixture.cs | Migrated tracking proxy tests with preserved middleware ordering |
| TrackingFixture.cs | Updated tracking tests to use factory pattern |
| AttributeBasedTrackingFixture.cs | Converted attribute-based tracking tests |
| Various TagHelper fixtures | Migrated all tag helper test fixtures to factory pattern |
| Various other test fixtures | Updated remaining test fixtures including localization, multisite, and experience editor tests |
| Benchmark files | Updated benchmark classes to use WebApplicationFactory pattern |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...etCore.SDK.RenderingEngine.Integration.Tests/Fixtures/RequestDefaultsConfigurationFixture.cs
Outdated
Show resolved
Hide resolved
...etCore.SDK.RenderingEngine.Integration.Tests/Fixtures/RequestDefaultsConfigurationFixture.cs
Outdated
Show resolved
Hide resolved
.../Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/RequestMappingFixture.cs
Outdated
Show resolved
Hide resolved
...spNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/Localization/LocalizationFixture.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/TestWebApplicationProgram.cs
Outdated
Show resolved
Hide resolved
...tCore.SDK.RenderingEngine.Integration.Tests/Fixtures/TagHelpers/TextFieldTagHelperFixture.cs
Outdated
Show resolved
Hide resolved
tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks/TrackingBenchmarks.cs
Outdated
Show resolved
Hide resolved
...s/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/ErrorHandlingFixture.cs
Outdated
Show resolved
Hide resolved
…ting up the response in the constructor consistently in EdgeSitemapProxyFixture
Migrate integration test fixtures to shared TestWebApplicationFactory
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...ngEngine.Integration.Tests/Fixtures/ExperienceEditor/ExperienceEditorCustomRoutingFixture.cs
Outdated
Show resolved
Hide resolved
tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks/RenderingEngineBenchmarks.cs
Outdated
Show resolved
Hide resolved
…ISitecoreLayoutClient singleton instead of constructing a sampleRequest/sampleResponse.- ExperienceEditorCustomRoutingFixture.cs
- Use the same approach TestServerBuilder used: register a simple mock ISitecoreLayoutClient singleton instead of constructing a sampleRequest/sampleResponse.- ExperienceEditorCustomRoutingFixture.cs - wire layout service to mock HttpClient in RenderingEngine benchmarks
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/TestWebApplicationProgram.cs
Outdated
Show resolved
Hide resolved
...e.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/Tracking/TrackingProxyFixture.cs
Show resolved
Hide resolved
...e.SDK.RenderingEngine.Integration.Tests/Fixtures/TagHelpers/RichTextFieldTagHelperFixture.cs
Show resolved
Hide resolved
...s/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/ErrorHandlingFixture.cs
Show resolved
Hide resolved
tests/Sitecore.AspNetCore.SDK.RenderingEngine.Benchmarks/TrackingBenchmarks.cs
Outdated
Show resolved
Hide resolved
- use app.Start() in TestWebApplicationProgram - Add comment explaining variable startedServer - Use the same layout-service builder pattern previously used in TrackingBenchmarks
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...e.SDK.RenderingEngine.Integration.Tests/Fixtures/TagHelpers/RichTextFieldTagHelperFixture.cs
Outdated
Show resolved
Hide resolved
...tecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/Tracking/TrackingFixture.cs
Show resolved
Hide resolved
...SDK.RenderingEngine.Integration.Tests/Fixtures/SearchOptimization/EdgeSitemapProxyFixture.cs
Outdated
Show resolved
Hide resolved
...AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/RequestHeadersValidationFixture.cs
Outdated
Show resolved
Hide resolved
...s/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/ErrorHandlingFixture.cs
Show resolved
Hide resolved
…n EdgeSitemapProxyFixture
…ctor pattern like other fixtures
- use _ = _factory.Server; to clearly indicate the variable is intentionally - using the more modern collection expression syntax for consistency in EdgeSitemapProxyFixture - Refactor RequestHeadersValidationFixture to implement similar constructor pattern like other fixtures
|
I think it is looking fine, when will it be merged? |
Description / Motivation
This PR removes the legacy
TestServerBuilderusage from the test and benchmark suites and migrates integration tests to theWebApplicationFactory<TestWebApplicationProgram>pattern (TestWebApplicationFactory). It preserves each fixture’s middleware and service ordering (rendering engine, experience editor, tracking, localization, forwarded headers, visitor identification, etc.) and keeps per-test substitutes/mock handlers where tests rely on specific layout responses.Key changes
TestServerBuilder/TestServerwithWebApplicationFactory<TestWebApplicationProgram>in all integration tests and benchmarks.TestServer.CreateClient()/Servicesusage withfactory.CreateClient()/factory.Servicesand updated disposal.Added/kept per-test
ISitecoreLayoutClientandISitecoreLayoutSerializersubstitutes where fixtures require specific SitecoreLayoutResponse content (e.g., Experience Editor cases that mapdatabaseName = "master").WebApplicationFactoryand registered mockHttpMessageHandlersviaHttpClientFactoryfor consistent handler injection.TestServerDefaultsruns before per-fixture mock registrations so mocks are not overwritten).Fixes #36
Testing
Terms